<?php
$propertyStr = Yii::t('BWeSport', 'Property');
$contentStr = Yii::t('BWeSport', 'Content');
$venderIdStr = Yii::t('BWeSport', 'Vender ID');
$loadVenderInfoStr = Yii::t('BWeSport', 'Load Vender Info');
$venderNameStr = Yii::t('BWeSport', 'Vender Name');
$venderImgStr = Yii::t('BWeSport', 'Vender Img');
$venueAddressStr = Yii::t('BWeSport', 'Venue address');
$venderPhoneStr = Yii::t('BWeSport', 'Vender phone');
$screen = Blyn::app()->getUIManager()->getCurrentScreen();

$messageNameField = 'message_vender';
$venderIdField = 'media_venderId_vender';
$venderNameField = 'media_venderName_vender';
$venueAddressField = 'media_venueAddress_vender';
$venderPhoneField = 'media_venderPhone_vender';
$imageField = 'image_media_image_vender';
$vMessageId = 0;

$model->addField($messageNameField);
$model->addField($venderIdField);
$model->addField($venderNameField);
$model->addField($venueAddressField);
$model->addField($venderPhoneField);
$model->addField($imageField);

$model->$messageNameField = 'vender';

if ($eventId > 0) {
    $event = new BWEvent($eventId);
    $vender = $event->getMessageManager()->getMessage('vender');
    $vMessageId = $vender->getId();

    $model->$messageNameField = $vender->name;
    $model->$venderIdField = $vender->getMediaManager()->getMedia('venderId')->getContent();
    $model->$venderNameField = $vender->getMediaManager()->getMedia('venderName')->getContent();
    if($vender->getMediaManager()->getMedia('venueAddress'))
        $model->$venueAddressField = $vender->getMediaManager()->getMedia('venueAddress')->getContent();
    if($vender->getMediaManager()->getMedia('venderPhone'))
        $model->$venderPhoneField = $vender->getMediaManager()->getMedia('venderPhone')->getContent();
    $imageMedia = $vender->getMediaManager()->getMedia('image');
    if ($imageMedia)
        $model->$imageField = $vender->getMediaManager()->getMedia('image')->content;
}
?>

<?php echo $form->hiddenField($model, $messageNameField, array('value' => 'vender message')); ?>

<table class="table table-hover">
    <colgroup>
        <col class="span1">
        <col class="span3">
    </colgroup>
    <thead>
        <tr>
            <th><?php echo $propertyStr; ?></th>
            <th><?php echo $contentStr; ?></th>
        </tr>
    </thead>
    <tbody>

        <tr><td> <?php echo  '<nobr style="color: red;font-size:20px">*</nobr>'. $venderIdStr; ?></td>
            <td><?php echo $form->textField($model, $venderIdField, array('placeholder' => $venderIdStr . '...', 'required' => true)); ?></td>
        </tr>

        <tr><td> <?php echo '<nobr style="color: red;font-size:20px">*</nobr>'. $venderNameStr; ?> </td>
            <td><?php echo $form->textField($model, $venderNameField, array('placeholder' => $venderNameStr . '...', 'required' => true)); ?></td>
        </tr>
        <tr><td> <?php echo '<nobr style="color: red;font-size:20px">*</nobr>'. $venderPhoneStr; ?> </td>
            <td><?php echo $form->textField($model, $venderPhoneField, array('placeholder' => $venderPhoneStr . '...', 'required' => true)); ?></td>
        </tr>
        <tr><td> <?php echo '<nobr style="color: red;font-size:20px">*</nobr>'. $venueAddressStr; ?> </td>
            <td><?php echo $form->textField($model, $venueAddressField, array('placeholder' => $venueAddressStr . '...', 'required' => true)); ?></td>
        </tr>
        <tr><td><?php echo  $venderImgStr; ?> </td>
            <td>
                <?php
                echo $form->fileField($model, $imageField);
                if ($vMessageId > 0) {
                    $imageUrl = Yii::app()->request->baseUrl . $model->$imageField;
                    echo "<img src=" . $imageUrl . " width=50 height=50 />";
                }
                ?>
            </td>
        </tr>
    </tbody>
</table>


